import React, { useEffect, useState } from 'react'

export default function HookTitleChange() {
  const [count, setCount] = useState(0);

  //dom渲染好之后触发 此后不管更新还是渲染 都会触发
  useEffect(() => {
    document.title = count;
  })
  
  return (
    <div>
      <h2>当前计数：{count}</h2>
      <button onClick={e => setCount(count + 1)}>+1</button>
    </div>
  )
}
